package com.ccc.oa.common.core.excepiton;

import com.ccc.oa.common.core.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * --- 代码敲对！ ---
 *
 * @author CCCccc
 * @create 2025/10/11
 * 备注：全局异常处理
 */
@Slf4j
// 该注解表示该类为全局异常处理类
@RestControllerAdvice
public class GlobalExceptionAdvice {
    // 处理自定义异常
    @ExceptionHandler(value = CommonExcepiton.class)
    public R handleCustomException(CommonExcepiton e) {
        log.error("自定义异常：{}", e.getMessage());
        return R.fail(e.getMsg());
    }
}
